import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'

import actProcessService from '/@/api/cn/core/act/actProcessService'

import type { ActProcess } from '/@/model/cn/core/act/eo/ActProcess'
import type { ActProcessQO } from '/@/model/cn/core/act/qo/ActProcessQO'
import type { ActProcessVO } from '/@/model/cn/core/act/vo/ActProcessVO'

interface ActProcessState {
}

export const useActProcessStore = defineStore({
  id: 'actProcess',
  state: (): ActProcessState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.save(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.saveBatch(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.update(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.updateBatch(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.remove(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ActProcess>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.removeBatch(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ActProcessQO>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.count(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ActProcessQO>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.pk(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ActProcessQO>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.query(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ActProcessQO>): Promise<Res<ActProcess>> {
      return new Promise<Res<ActProcess>>((resolve, reject) => {
        actProcessService.paging(param).then((res: AxiosResponse<Res<ActProcess>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ActProcessQO>): Promise<Res<ActProcessVO>> {
      return new Promise<Res<ActProcessVO>>((resolve, reject) => {
        actProcessService.countVo(param).then((res: AxiosResponse<Res<ActProcessVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ActProcessQO>): Promise<Res<ActProcessVO>> {
      return new Promise<Res<ActProcessVO>>((resolve, reject) => {
        actProcessService.pkVo(param).then((res: AxiosResponse<Res<ActProcessVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ActProcessQO>): Promise<Res<ActProcessVO>> {
      return new Promise<Res<ActProcessVO>>((resolve, reject) => {
        actProcessService.queryVo(param).then((res: AxiosResponse<Res<ActProcessVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ActProcessQO>): Promise<Res<ActProcessVO>> {
      return new Promise<Res<ActProcessVO>>((resolve, reject) => {
        actProcessService.pagingVo(param).then((res: AxiosResponse<Res<ActProcessVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useActProcessStoreWithout() {
  return useActProcessStore(store)
}
